<?php

namespace app\common\repositories\bill;

use app\common\repositories\BaseRepository;
use app\common\dao\bill\BillPictureDao;

/**
 * @mixin BillPictureDao
 */
class BillPictureRepository extends BaseRepository
{

    public function __construct(BillPictureDao $dao)
    {
        $this->dao = $dao;
    }

    public function addPicture(int $billId, int $courseId, array $data, $catalogId = 0)
    {
        $insertData = [];
        foreach ($data as $k => $v) {
            if ($v) {
                $insertData[] = [
                    'image_url' => $v,
                    'bill_id' => $billId,
                    'course_id' => $courseId,
                    'catalog_id' => $catalogId
                ];
            }
        }
        return $this->dao->insertAll($insertData);
    }

}
